﻿using System.Web;
using System.Web.UI;

namespace MyHealthByDesign.Helper
{
    public class ValidationError : IValidator
    {
        public void Validate()
        {
           //no actin required
        }

        public bool IsValid { get; set; }
        public string ErrorMessage { get; set; }

        public ValidationError(string message)
        {
            ErrorMessage = message;
            IsValid = false;
        }

        public ValidationError()
        {
        }

        public void DisplayErrorMessage(string message)
        {
            var currentPage = HttpContext.Current.Handler as Page;
            if (currentPage != null) currentPage.Validators.Add(new ValidationError(message));
        }
    }
}